# -*- coding: utf-8 -*-
'''
    :file: __init__.py
    :author: -Farmer
    :url: https://blog.farmer233.top
    :date: 2021/02/09 01:02:45
'''

from flask import Flask, g
from flask_sqlalchemy import SQLAlchemy
from flask_httpauth import HTTPAuth, HTTPBasicAuth

app = Flask(__name__)
app.config.from_pyfile('settings.py')

db = SQLAlchemy(app)
auth = HTTPBasicAuth()

from app.models import User

@auth.verify_password
def verify_password(username, password):
    user = User.query.filter_by(username = username).first()
    if not user or not user.validate_password(password):
        return False
    g.user = user
    return True

from app import views, commands, models